package com.study.mike.common.utils;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;

/**
 * @author kh
 */
public class AesHuTool {
    String content = "test中文";
    //随机生成密钥

    byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();

    //构建

    AES aes = SecureUtil.aes(key);

    //加密

    byte[] encrypt = aes.encrypt(content);

    //解密

    byte[] decrypt = aes.decrypt(encrypt);

    //加密为16进制表示

    String encryptHex = aes.encryptHex(content);

    //解密为原字符串

    String decryptStr = aes.decryptStr(encryptHex);

}
